<?php

function is_user_agent_ie() {
    if (isset($_SERVER['HTTP_USER_AGENT']) &&
            (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false))
        return true;
    else
        return false;
}
?>
<script src="<?php echo javascript_path('jquery.autocomplete.js') ?>"></script> 
<div class="login_wrapper">
    <div class="dark_header">
        <div class="login_page_login_table_wrapper">
            <form action="<?php echo url_for('@sf_guard_signin') ?>" method="post">
                <?php echo $form['_csrf_token'] ?>
                <table class="login_page_login_table" align="right" width="40%">
                    <tr>
                        <td class="login_username">
                            Username
                        </td>
                        <td class="login_password">
                            Password
                        </td>
                        <td>

                        </td>
                    </tr>
                    <tr>
                        <td class="login_smaller_input">
                            <?php echo $form['username'] ?>
                        </td>
                        <td class="login_smaller_input">
                            <?php echo $form['password'] ?>
                        </td>
                        <td>
                            <input type="image" src="<?php echo image_path('login_page_login.gif') ?>"/>
                        </td>
                    </tr>
                    <tr>
                        <td class="keepme">
                            <input type="checkbox" id="keepme"/>
                            <label class="hint" for="keepme"><?php echo __('Keep me logged in') ?></label>
                            <div class="clear"></div>
                        </td>
                        <td class="hint">
                            <a href="<?php echo url_for2("forget_password") ?>"><?php echo __('Forgot your password? or need help?') ?></a>
                        </td>
                        <td>
                        </td>
                    </tr>
                </table>
            </form>
            <div class="clear"></div>
            <?php if ($sf_user->hasFlash('error')) { ?>
                <script>
                    $('.login_smaller_input input').addClass('error');
                </script>
            <?php } ?>
        </div>
        <div class="clear"></div>
    </div>
    <div class="login_main">
        <div class="social">
            <div class="fb-like" data-href="http://doseyeh.com" data-send="false" data-layout="button_count" data-width="80" data-show-faces="false"></div>
            <!-- Place this tag where you want the +1 button to render -->
            <g:plusone size="medium" annotation="inline" width="120"></g:plusone>
            <a href="https://twitter.com/share" class="twitter-share-button"><?php echo __('Tweet') ?></a>
        </div>
        <div class="login_table_wrap">
            <form id="login" action="<?php echo url_for('default/login') ?>" method="post">
                <?php echo $create_account_form['_csrf_token'] ?>
                <?php if ($sf_user->hasFlash('notice')) { ?>
                    <div class="notice">
                        <?php echo $sf_user->getFlash('notice') ?>
                    </div>
                <?php } ?>
                <table>
                    <tr>
                        <td></td>
                        <td class="create_account"><?php echo __('Create your Doseyeh account') ?></td>
                    </tr>
                    <tr>
                        <th><?php echo __('Name') ?></th>
                        <td><?php echo $create_account_form['first_name']->render($create_account_form['first_name']->renderError() != '' ? array('class' => 'field_error') : array()) ?></td>
                        <td><?php echo $create_account_form['first_name']->renderError() ?></td>
                    </tr>
                    <tr>
                        <th><?php echo __('Email') ?></th>
                        <td><?php echo $create_account_form['email_address']->render($create_account_form['email_address']->renderError() != '' ? array('class' => 'field_error') : array('autocomplete' => 'off')) ?></td>
                        <td><?php echo $create_account_form['email_address']->renderError() ?></td>
                    </tr>
                    <tr>
                        <th><?php echo __('Password') ?></th>
                        <td><?php echo $create_account_form['password']->render($create_account_form['password']->renderError() != '' ? array('class' => 'field_error') : array()) ?></td>
                        <td><?php echo $create_account_form['password']->renderError() ?></td>

                    </tr>
                    <tr>
                        <th>Re-Enter Password</th>
                        <td><?php echo $create_account_form['password_again']->render($create_account_form['password_again']->renderError() != '' ? array('class' => 'field_error') : array()) ?></td>
                        <td><?php echo $create_account_form['password_again']->renderError() ?></td>

                    </tr>
                    <tr>
                        <th><?php echo __('University') ?></th>
                        <td>
                            <div class="dos_select">
                                <?php echo $create_account_form['university_id']->render($create_account_form['university_id']->renderError() != '' ? array('class' => 'field_error') : array()) ?>
                            </div>
                        </td>
                        <td><?php echo $create_account_form['university_id']->renderError() ?></td>

                    </tr>
                    <tr>
                        <th><?php echo __('Faculty') ?></th>
                        <td>
                            <div class="dos_select">
                                <?php echo $create_account_form['faculty_id']->render($create_account_form['faculty_id']->renderError() != '' ? array('class' => 'field_error') : array()) ?>
                            </div>
                        </td>
                        <td><?php echo $create_account_form['faculty_id']->renderError() ?></td>

                    </tr>
                    <tr>
                        <td></td>
                        <td align="right">


                            <div class="myButton"><input type="submit" value="<?php echo __('Register') ?>"></div>


                        </td>
                    </tr>
                </table>
            </form>
        </div>
        <div class="or dblue"><?php echo __('Or') ?></div>
        <div class="facebook_twitter">
            <div>
                <?php $link = 'http://www.facebook.com/dialog/oauth?client_id=' . sfConfig::get('app_facebook_app_id') . '&redirect_uri=' . url_for('user/facebook_logged_in', true) . '&scope=email&display=popup' ?>
                <a onclick="window.open(this.href<?php if (!is_user_agent_ie()) { ?>,'facebook login','width=410,height=285'<?php } ?>);return false;" href="<?php echo $link ?>" class="iframe">
                    <img src="<?php echo image_path('loginpage_facebook.gif') ?>"/>
                </a>
            </div>


        </div>
        <div class="bottom_users">
            <ul>
                <?php foreach ($users_pictures as $k => $one) { ?>
                    <?php if ($k == 9) break ?>
                    <?php if (file_exists($one)) { ?>
                        <li><img src="<?php echo get_resized_image(50, 50, $one, false, true) ?>"/></li>
                    <?php } ?>
                <?php } ?>
            </ul>
        </div>
    </div>
</div>

<script>
    
    $('#autocomplete_sf_guard_user_faculty_id').bind("change mouseover click keyup", function() {
        $("#autocomplete_sf_guard_user_faculty_id").flushCache();
    });
</script>
